﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZHDJ.Core;
using ZHDJ.Data.DataCaching;
using ZHDJ.WebPage;

namespace ZHDJ.Web.Portal
{
    public partial class ExportWordTest : System.Web.UI.Page
    {
        /// <summary>
        /// 网站域名
        /// </summary>
        public string WebHost
        {
            get { return SystemParameterCaching.Get(SystemParameterKey.WebHost); }
        }
        public string AppllicationID
        {
            get { return Request.QueryString["AppllicationID"].ToString(); }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var html =
                    HttpRequestBusiness.WebContentByGet(WebHost + "/App/JoinParty/Template/TJoinStep19ForHtml.aspx?AppllicationID=" + AppllicationID,
                        true, WebHost + "/Login.aspx?LoginType=2");
                htmlEditor.Text = html;
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {

            WordBusiness.Export(this, htmlEditor.Text, "填写入党志愿书.doc");
            //System.IO.StringWriter SW = new System.IO.StringWriter();
            //System.Web.UI.HtmlTextWriter HTW = new System.Web.UI.HtmlTextWriter(SW);
            //wod.RenderControl(HTW);
            ////Page为要导出的对象,当前是Page,如果是DataGrid,DataList等都可以
            //Response.Buffer = true;
            //Response.Clear();
            //Response.ClearContent();
            //Response.ClearHeaders();
            //Response.ContentType = "application/ms-word";
            ////Response.ContentType是输出流的 HTTP MIME 类型
            ////Response.ContentType      --- word文件
            ////application/vnd.ms-excel --- excel文件
            ////
            //Response.Charset = "utf-8";
            //Response.ContentEncoding = System.Text.Encoding.GetEncoding("GBK");
            //Response.AddHeader("Content-Disposition", "attachment;filename=XXX.doc");
            ////attachment --- 作为附件下载
            ////inline --- 在线打开
            ////filename如过是中文,则可以用HttpUtility.UrlEncode(fileName,System.Text.Encoding.UTF8)
            ////进行进行编码,以解决文件名乱码的问题
            //Response.Write(SW.ToString());
            //Response.Flush();
            //Response.Close();
        }
    }
}